<extend name="Base/common"/>

<block name="style">
    <link href="__CSS__/event.css" rel="stylesheet" type="text/css"/>
    <link type="text/css" rel="stylesheet" href="__PUBLIC__/Core/js/ext/magnific/magnific-popup.css"/>
</block>

<block name="body">

<!--导航-->
<include file="_nav"/>




    <div class="col-md-3 pull-right" style="z-index: 99">
        <include file="_right"/>
    </div>


    <div class="col-md-9">

        <div class="forum_module " style="width: 100%; min-height: 500px;padding: 0;padding-top: 10px">
            <div class="clearfix">
                <div class="mgl20 event_title clearfix"><a href="javascript:" onclick="location.href='{:U('Event/Index/detail',array('id'=>$content['id']))}'"
                                                  class="text-more" style="width: 85%;float: left"
                                                  title="{$content.title}">{$content.title}</a>

                    <div style=" margin-top: 10px;margin-bottom: 10px">
                        <div class="event_logo" style="background-position: -20px 0px;"></div>
                        <span class="event_count">&nbsp;{$content.view_count}</span>
                    </div>
                </div>
                <div style="padding: 17px 0 0 10px;position: relative">

                    <a class="pull-left" href="javascript:" onclick="location.href='{:U('Event/Index/detail',array('id'=>$content['id']))}'">
                        <img style="width: 345px;height: 210px;" src="{$content.cover_id|getThumbImageById=345,250}"/>

                        <div class="event_detail_type">{$content.type.title}</div>
                    </a>
                    <if condition="time() lt $content['eTime']">
                        <div class="event_state" style="background: #d61f39;">
                            正在进行
                        </div>
                        <else/>
                        <div class="event_state" style="background: #000;">
                            已结束
                        </div>
                    </if>

                </div>
                <div class="pull-left col-xs-12 col-md-6" >

                    <div class="event_fq_count pull-left">

                        <div class="pull-left mgl20" style="width: 100%;font-size: 14px;">发起人：&nbsp; <a class=""
                                                                                                        href="{$content.user.space_url}">
                            <span class="event_count">{$content.user.nickname}</span></a></div>


                        <p>

                        <div class="pull-left mgl20 mgt10 " style="font-size: 14px;width: 100%">时间：
                            {:date('Y-m-d',$content['sTime'])}--{:date('Y-m-d',$content['eTime'])}
                        </div>
                        </p>

                        <p>

                        <div class="pull-left mgl20 mgt10 " style="font-size: 14px;width: 90%">地点：
                            {$content.address}
                        </div>
                        </p>

                        <p>

                        <div class="pull-left mgl20 mgt10 " style="font-size: 14px;width: 100%">截止时间：
                            {:date('Y-m-d H:i',$content['deadline'])}
                        </div>
                        </p>

                        <div class="pull-left clearfix" style="width: 100%">
                            <div class=" pull-left mgl20 mgt10">
                                <span class="event_count">人数限制：&nbsp; {$content.limitCount}人</span>
                            </div>


                            <div class=" pull-left  mgl20 mgt10">
                                <span class="event_count">已报名：&nbsp;{$content.signCount}人</span>
                            </div>

                            <div class=" pull-left  mgl20 mgt10">
                                <span class="event_count">已参加：&nbsp;{$content.attentionCount}人</span>
                            </div>
                        </div>
                        <div class="pull-left mgl20 mgt10">
                            <div class="btn-group">

                                <php>if($content['uid'] == is_login() || is_administrator(is_login())){</php>

                                <if condition="time() lt $content['eTime']">
                                    <a id="endEvent" class="btn btn-default">提前结束</a>
                                </if>

                                <a href="{:U('edit',array('id'=>$content['id']))}" class="btn btn-default">编辑活动</a>
                                <a id="delEvent" class="btn btn-default">删除活动</a>
                                <php>}if($content['uid'] != is_login() || is_administrator(is_login())){</php>
                                <php>if(!$check_isSign){</php>
                                <php>if($content['deadline'] < time()){</php>
                                <a class="btn btn-default  " href="javascript:"
                                   onclick="toast.error('报名已截止')">报名已截止 </a>
                                <php>}else{</php>
                                <if condition="is_login() eq 0">
                                    <a class="btn  btn-info   " href="javascript:"style="color: #fff"
                                       onclick="toast.error('请登陆后再报名')">报名参加 </a>
                                    <else/>
                                    <a class="btn  btn-info  event_sign " style="color: #fff"
                                       href="{:U('ajax_sign',array('event_id'=>$content['id']))}">报名参加 </a>
                                </if>
                                <php>}</php>
                                <php>}else{</php>
                                <a class="btn btn-default" href="javascript:"
                                   id="unSign">取消报名 </a>

                                <span style="line-height: 34px;float: left"> 已报名&nbsp;&nbsp;&nbsp;&nbsp;<if
                                        condition="$check_isSign[0]['status'] eq 1">已审核
                                    <else/>
                                    未审核
                                </if></span>
                                <php>}
                                    }</php>



                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div style="font-size: 18px;padding: 30px 0 10px 20px;">活动详情</div>
            <div class="word-wrap detail" style="padding: 5px 20px 50px 20px;color: #848484">
                {$content.explain}

                <div class="pull-right" style="color: #999;font-size: 12px;">
                    发布时间： {$content.create_time|friendlyDate} &nbsp;&nbsp;
                    更新时间： {$content.update_time|friendlyDate}
                </div>

            </div>


            <div class="clearfix"></div>
            <div style="padding: 5px 20px 50px 20px;">
                {:hook('localComment', array('path'=>"Event/event/$content[id]", 'uid'=>$content['uid']))}
            </div>

        </div>
    </div>


</block>

<block name="script">
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Core/js/ext/magnific/jquery.magnific-popup.min.js"></script>
    <script>
        $(function () {
            $('#top_nav >li >a ').mouseenter(function () {
                $('.children_nav').hide();
                $('#children_' + $(this).attr('data')).show();
            });


            $('.event_sign').magnificPopup({
                type: 'ajax',
                overflowY: 'scroll',
                modal: true,
                callbacks: {
                    ajaxContentAdded: function () {
                        console.log(this.content);
                    }
                }
            });


            bindSupport();
            /**
             * 取消报名
             * */
            $('#unSign').click(function () {
                if (confirm('确定要取消报名么？')) {
                    var event_id = "{$content['id']}";
                    $.post("{:U('Event/Index/unSign')}", {event_id: event_id}, function (res) {
                        if (res.status) {
                            toast.success(res.info);
                            setTimeout(function () {
                                location.reload();
                            }, 1500);
                        }
                        else {
                            toast.error(res.info);
                        }
                    }, 'json');
                }
            });
            /**
             * 删除活动事件
             * */
            $('#delEvent').click(function () {
                if (confirm('确定要删除活动么？')) {
                    var event_id = "{$content['id']}";
                    $.post("{:U('Event/Index/doDelEvent')}", {event_id: event_id}, function (res) {
                        if (res.status) {
                            toast.success(res.info);
                            setTimeout(function () {
                                location.href = "{:U('index')}";
                            }, 1500);
                        }
                        else {
                            toast.error(res.info);
                        }
                    }, 'json');
                }
            });
            /**
             * 提前结束活动点击事件
             */
            $('#endEvent').click(function () {
                if (confirm('确定要提前结束活动么？')) {
                    var event_id = "{$content['id']}";
                    $.post("{:U('Event/Index/doEndEvent')}", {event_id: event_id}, function (res) {
                        if (res.status) {
                            toast.success(res.info);
                            setTimeout(function () {
                                location.reload();
                            }, 1500);
                        }
                        else {
                            toast.error(res.info);
                        }
                    }, 'json');
                }
            });
        })
    </script>

</block>

